package com.cloudpivot.receivales.workorder.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * 工单报告 对外接口
 */
@Controller
@RequestMapping("/CalendarTest")
@Slf4j
@CrossOrigin("*")
public class TestCalendarForController {

    /**
     * 回调用户信息
     */
    @GetMapping("/userTask")
    @ResponseBody
    public JSONArray userTask() {
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject1 = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        jsonObject.put("id", "0");
        jsonObject.put("title", "后端的任务");
        jsonObject.put("start", "2023-08-05T08:00:00");
        jsonObject.put("end", "2023-08-05T016:00:00");
        jsonObject1.put("id", "1");
        jsonObject1.put("title", "后端的任务");
        jsonObject1.put("start", "2023-08-10T08:00:00");
        jsonObject1.put("end", "2023-08-10T016:00:00");
        jsonArray.add(jsonObject);
        jsonArray.add(jsonObject1);
        return jsonArray;

    }

    private String formtDate(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss");
        String _res = sdf.format(new Date());
        return _res;
    }

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public String exceptionHandler(Exception exception) {
        System.out.println("all处理异常");
        exception.toString();
        return exception.toString();
    }

    @ResponseStatus(code = HttpStatus.OK)
    @ExceptionHandler(value=ArithmeticException.class)
    public void mathHandler(ArithmeticException exception) {
        System.out.println("math异常");
        exception.toString();
    }

}
